<template>
	<view class="container">
		<view class="title">校园通讯录</view>
		<view class="list-box">
			<view class="item-box">
				
				<view class="item" v-for="(item,index) in studentList" :key="item.Id">
					<view class="item-title">{{item.RealName}}</view>
					<view class="item-line"></view>
					<view class="book-box" v-for="(teacher,index) in item.TeacherList" :key="teacher.Id">
						<view class="book-img">
							<image class="img" src="https://public-1300796766.cos.ap-guangzhou.myqcloud.com/mini/1.jpg"></image>
						</view>
						<view class="book-content">
							<view class="content-top">
								<view class="name">姓名：{{teacher.RealName}}</view>
								<view class="mobile">电话：{{teacher.Phone}}</view>
							</view>
							<view class="content-bottom">所教科目：{{teacher.CourseName}}</view>
						</view>
					</view>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	import {myRequest} from '../../utils'
	
	export default {
		data() {
			return {
				studentList: [],
				timer: null
			}
		},
		
		onShow() {
			
			let that = this
			
			uni.showLoading({
				title: '拼命加载中...',
				success() {
					
					if (that.timer != null) {
						clearTimeout(that.timer)
					}
					
					that.timer = setTimeout(function() {
						
						myRequest({
							url: '/api/user/teacher_book',
							data: {},
						}, function(res) {
							
							uni.hideLoading()
							
							if (res.statusCode != 200) {
								uni.showModal({
									title: '提示',
									content: '服务器错误，请求失败'
								})
								return
							}
							
							if (res.data.status != 0) {
								uni.navigateTo({
									url: '/pages/login/login'
								})
								return
							}
							
							that.studentList = res.data.data
							
						})
						
					}, 1000)
					
				}
			})
			
		},
		
		methods: {
	
		}
	}
</script>

<style>
	.container {
		width: 750rpx;
		height: auto;
		background-image: linear-gradient(#ffae00, #eee, #efefef);
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-bottom: 160rpx;
		min-height: 1800rpx;
	}

	.title {
		width: 560rpx;
		display: flex;
		align-items: center;
		font-size: 48rpx;
		margin-top: 20rpx;
		margin-bottom: 20rpx;
	}

	.list-box {
		width: 650rpx;
		height: auto;
		background-color: #ffffff;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.item {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 580rpx;
		margin-bottom: 40rpx;
	}

	.item-title {
		display: flex;
		align-items: center;
		font-size: 36rpx;
		width: 100%;
		height: 80rpx;
		padding-left: 50rpx;
	}

	.item-line {
		width: 100%;
		height: 10rpx;
		background-color: #fec901;
		box-shadow: 0rpx 0rpx 18rpx 0px rgba(119, 119, 119, 0.27);
		border-radius: 4px;
	}

	.book-box {
		width: 100%;
		display: flex;
		align-items: center;
		position: relative;
		margin-top: 50rpx;
	}

	.book-img {
		width: 110rpx;
		height: 110rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 50%;
		box-shadow: 6rpx 4rpx 18rpx 0rpx rgba(145, 124, 24, 0.49);
		position: absolute;
		z-index: 100;
		background-color: #ffffff;
	}

	.img {
		width: 90rpx;
		height: 90rpx;
		border-radius: 50%;
	}

	.book-content {
		font-size: 26rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		box-shadow: 6rpx 4rpx 18rpx 0px rgba(145, 124, 24, 0.49);
		border-radius: 32rpx;
		height: 100rpx;
		margin-left: 46rpx;
		padding-right: 20rpx;
	}

	.content-top {
		display: flex;
		width: 100%;
		margin-left: 84rpx;
	}
	
	.name {
		width: 170rpx;
	}
	
	.content-bottom {
		margin-top: 4rpx;
		width: 100%;
		margin-left: 84rpx;
	}
</style>
